<include file="public@header" />
</head>
<style type="text/css">
    .file-wrap{
        height:34px;
        width: 82px;
        position: relative;
        display: inline-block;
        text-align: center;
        line-height: 34px;
        overflow: hidden;
        font-size: 14px;
        cursor: pointer;
        color: #fff;
        vertical-align: middle;
        background-color: #1a242f;
        border-color: #161f29;
    }
    .file-wrap input{
        position: absolute;
        height: 40px;
        z-index: 2;
        right: 0;
        top: 0;
        filter: alpha(opacity=0);
        -moz-opacity: 0;
        opacity: 0;
        cursor: pointer;
        font-size: 16px;
    }
</style>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('star/index')}">明星列表</a></li>
			<li><a href="{:url('star/add')}">明星添加</a></li>
			<li class="active"><a>明星修改</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('star/editPost')}">
			<div class="form-group">
				<label for="input-s_name" class="col-sm-2 control-label"><span class="form-required">*</span>姓名</label>
				<div class="col-md-6 col-sm-10">
                    <input type="hidden" name="id" value="{$star.id}">
					<input type="text" class="form-control" id="input-s_name" name="s_name" value="{$star.s_name}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_booked" class="col-sm-2 control-label"><span class="form-required">*</span>关注人数</label>
				<div class="col-md-6 col-sm-10">
					<input type="number" class="form-control" id="input-s_booked" value="{$star.s_booked}" disabled>
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_price" class="col-sm-2 control-label"><span class="form-required">*</span>直播金额（分）</label>
				<div class="col-md-6 col-sm-10">
					<input type="number" class="form-control" id="input-s_price" name="s_price" min="0" max="1000" value="{$star.s_price}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_ratio" class="col-sm-2 control-label"><span class="form-required">*</span>分成比例（%）</label>
				<div class="col-md-6 col-sm-10">
					<input type="number" class="form-control" id="input-s_ratio" name="s_ratio" min="0" max="100" value="{$star.s_ratio}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_class" class="col-sm-2 control-label"><span class="form-required">*</span>视频文件夹ID</label>
				<div class="col-md-6 col-sm-10">
					<input type="number" class="form-control" id="input-s_class" value="{$star.s_class}" disabled>
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_image1" class="col-sm-2 control-label"><span class="form-required">*</span>封面/背景</label>
				<div class="col-md-3 col-sm-5">
					<img src="{$star.s_image}" id="img1" width="128" style="cursor: pointer"/>
					<div id="file-wrap1" class="file-wrap">
						<input type="file" onchange="upload1(this)" accept="image/jpg,image/jpeg,image/png" id="input-s_image1" name="file" style="display: inline"/>
						选择图片
					</div>
					<input type="button" class="btn btn-default" id="cancel_img1" onclick="cancel1();" value="取消图片" style="display: none">
					<input type="hidden" name="path1" id="path1" value="">
					<input type="hidden" name="file1" id="file1" value="">
					<input type="hidden" name="s_image" value="{$star.s_image}">
					<p class="help-block">头像支持jpg,png,jpeg格式,文件大小最大不能超过1M</p>
				</div>
				<div class="col-md-3 col-sm-5">
					<img src="{$star.s_backdrop}" id="img2" width="128" style="cursor: pointer"/>
					<div id="file-wrap2" class="file-wrap">
						<input type="file" onchange="upload2(this)" accept="image/jpg,image/jpeg,image/png" id="input-s_image2" name="file" style="display: inline"/>
						选择图片
					</div>
					<input type="button" class="btn btn-default" id="cancel_img2" onclick="cancel2();" value="取消图片" style="display: none">
					<input type="hidden" name="path2" id="path2" value="">
					<input type="hidden" name="file2" id="file2" value="">
					<input type="hidden" name="s_backdrop" value="{$star.s_backdrop}">
					<p class="help-block">背景支持jpg,png,jpeg格式,文件大小最大不能超过1M</p>
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_language" class="col-sm-2 control-label"><span class="form-required">*</span>语言</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-s_language" name="s_language" value="{$star.s_language}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_astro" class="col-sm-2 control-label"><span class="form-required">*</span>星座</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-s_astro" name="s_astro" value="{$star.s_astro}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_born" class="col-sm-2 control-label"><span class="form-required">*</span>出生地</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-s_born" name="s_born" value="{$star.s_born}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_agency" class="col-sm-2 control-label"><span class="form-required">*</span>经济公司</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-s_agency" name="s_agency" value="{$star.s_agency}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_musictype" class="col-sm-2 control-label"><span class="form-required">*</span>音乐类型</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-s_musictype" name="s_musictype" value="{$star.s_musictype}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_debut" class="col-sm-2 control-label"><span class="form-required">*</span>出道时间</label>
				<div class="col-md-6 col-sm-10">
					<input type="number" class="form-control" id="input-s_debut" name="s_debut" value="{$star.s_debut}">
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_works" class="col-sm-2 control-label"><span class="form-required">*</span>代表作品</label>
				<div class="col-md-6 col-sm-10">
					<textarea class="form-control" id="input-s_works"  name="s_works" placeholder="请填写代表作品">{$star.s_works}</textarea>
				</div>
			</div>
			<div class="form-group">
				<label for="input-s_record" class="col-sm-2 control-label"><span class="form-required">*</span>主要成就</label>
				<div class="col-md-6 col-sm-10">
					<textarea class="form-control" id="input-s_record"  name="s_record" placeholder="请填写主要成就">{$star.s_record}</textarea>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-primary js-ajax-submit">修改</button>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
<script type="application/javascript">

    function cancel1() {
        $('#file-wrap1').show();
        $('#input-s_image1').val('').attr('style','display: inline');
        $('#img1').attr('src',"{$star.s_image}");
        $('#cancel_img1').attr('style','display: none');
        $('#pat1').attr('value','');
        $('#file1').attr('value','');
    }

    function cancel2() {
        $('#file-wrap2').show();
        $('#input-s_image2').val('').attr('style','display: inline');
        $('#img2').attr('src',"{$star.s_backdrop}");
        $('#cancel_img2').attr('style','display: none');
        $('#pat2').attr('value','');
        $('#file2').attr('value','');
    }

    function upload1(obj) {
        var $fileinput = $(obj);
        Wind.css("jcrop");
        Wind.use("ajaxfileupload", "jcrop", "noty", function () {
            $.ajaxFileUpload({
                url: "{:url('star/uploadImg')}",
                secureuri: false,
                fileElementId: "input-s_image1",
                dataType: 'json',
                data: {},
                success: function (data, status) {
                    if (data.code) {
                        $("#file-wrap1").hide();
                        $('#cancel_img1').show();
                        var src  = '{$simgs}'+ data.data.path + data.data.file;
                        $('#img1').attr('src',src);
                        $('#path1').attr('value',data.data.path);
                        $('#file1').attr('value',data.data.file);
                    } else {
                        noty({
                            text: data.msg,
                            type: 'error',
                            layout: 'center',
                            callback: {
                                afterClose: function () {
                                    reloadPage(window);
                                }
                            }
                        });
                        cancel1();
                    }
                },
                error: function (data, status, e) {
                    cancel1();
                    alert(e + '\r选择的图片文件错误。请重新选择！');
                }
            });
        });
        return false;
    }

    function upload2(obj) {
        var $fileinput = $(obj);
        Wind.css("jcrop");
        Wind.use("ajaxfileupload", "jcrop", "noty", function () {
            $.ajaxFileUpload({
                url: "{:url('star/uploadImg')}",
                secureuri: false,
                fileElementId: "input-s_image2",
                dataType: 'json',
                data: {},
                success: function (data, status) {
                    if (data.code) {
                        $("#file-wrap2").hide();
                        $('#cancel_img2').show();
                        var src  = '{$simgs}'+ data.data.path + data.data.file;
                        $('#img2').attr('src',src);
                        $('#path2').attr('value',data.data.path);
                        $('#file2').attr('value',data.data.file);
                    } else {
                        noty({
                            text: data.msg,
                            type: 'error',
                            layout: 'center',
                            callback: {
                                afterClose: function () {
                                    reloadPage(window);
                                }
                            }
                        });
                        cancel1();
                    }
                },
                error: function (data, status, e) {
                    cancel1();
                    alert(e + '\r选择的图片文件错误。请重新选择！');
                }
            });
        });
        return false;
    }
</script>
</body>
</html>